﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using YunShop_WebAPI.Model;
using static YunShop_WebAPI.BLL.SystemInfo;

namespace YunShop_WebAPI.BLL
{   
    public class ShopCommon
    {
        /// <summary>
        /// 微信用户登录
        /// </summary>
        public static ArrayList OnUserLogin(FMWxLogin entity, ref int status, ref string message)
        {
            string sql = @"select FAppSecret from t_MiniSetting where FAppID=@FAppID";
            SqlParameterList parlist = new SqlParameterList();
            parlist.Add("@FAppID", SqlDbType.VarChar, entity.appid);
            ArrayList dt = DBHelper.Select(sql, parlist.Get_List(),DBHelper.ConnMaster);
            return dt;
            //if (dt.Rows.Count > 0)
            //{
            //    //DataRow dr = dt.Rows[0];
            //    return dt;
            //}
            //return null;
        }

        /// <summary>
        /// 通过appid获取密钥
        /// </summary>
        /// <param name="appid"></param>
        /// <returns></returns>
        public static string GetAppSecret(string appid)
        {
            string sql = @"select FAppSecret from t_MiniSetting where FAppID=@FAppID";
            SqlParameterList parlist = new SqlParameterList();
            parlist.Add("@FAppID", SqlDbType.VarChar, appid);
            DataTable dt = DBHelper.GetDataTable(sql, parlist.Get_List(),DBHelper.ConnMaster);

            if (dt.Rows.Count > 0) {
                DataRow dr = dt.Rows[0];
                return CommonFun.ConvertToString(dr["FAppSecret"]);
            }
            return "";
        }
                
    }
}
